package com.xjy.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjy.common.core.mybatisplus.core.ServicePlusImpl;
import com.xjy.common.core.page.PagePlus;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.utils.PageUtils;
import com.xjy.system.domain.ReportProjContract;
import com.xjy.system.domain.bo.ReportProjContractQueryBo;
import com.xjy.system.domain.vo.ReportProjContractVo;
import com.xjy.system.mapper.ReportProjContractMapper;
import com.xjy.system.service.IReportProjContractService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 合同执行情况Service业务层处理
 *
 * @author mlb
 * @date 2022-03-17
 */
@Service
public class ReportProjContractServiceImpl extends ServicePlusImpl<ReportProjContractMapper, ReportProjContract> implements IReportProjContractService {

    @Override
    public ReportProjContractVo queryById(Long projId){
        return getVoById(projId, ReportProjContractVo.class);
    }

    @Override
    public TableDataInfo<ReportProjContractVo> queryPageList(ReportProjContractQueryBo bo) {
        PagePlus<ReportProjContract, ReportProjContractVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo), ReportProjContractVo.class);
        return PageUtils.buildDataInfo(result);
    }

    @Override
    public List<ReportProjContractVo> queryList(ReportProjContractQueryBo bo) {
        return listVo(buildQueryWrapper(bo), ReportProjContractVo.class);
    }

    private LambdaQueryWrapper<ReportProjContract> buildQueryWrapper(ReportProjContractQueryBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportProjContract> lqw = Wrappers.lambdaQuery();
        lqw.like(StrUtil.isNotBlank(bo.getProjName()), ReportProjContract::getProjName, bo.getProjName());
        lqw.eq(StrUtil.isNotBlank(bo.getContractType()), ReportProjContract::getContractType, bo.getContractType());
        return lqw;
    }


}
